package xyz.xmh.pattern.creational.singletonpattern;

/**
 * LazyLockSingleton
 * 加锁的懒汉单例，线程安全
 *
 * @author xuMingHai
 * @since 2021/4/27 星期二 18:08
 */
public class LazyLockSingleton {
    private static LazyLockSingleton instance;

    private LazyLockSingleton() {
    }

    public static synchronized LazyLockSingleton getInstance() {
        if (instance == null) {
            instance = new LazyLockSingleton();
        }
        return instance;
    }

    public void showMessage() {
        System.out.println("Hello LazyLockSingleton!");
    }
}
